<template>
    <van-nav-bar title="个人中心" left-text="返回" right-text="退出" left-arrow @click-left="$router.go(-1)"
        @click-right="onClickRight" />
    <van-cell-group title="个人中心">
        <van-cell title="地址管理" is-link to="/address" inset />
        <van-cell title="订单中心" is-link to="/order" inset />
    </van-cell-group>
</template>
<script lang='ts' setup>
import { useUserStore } from '@/stores/userStore';
import { useRouter } from 'vue-router'
let router = useRouter()
let userStore = useUserStore()
let onClickRight = () => {
    router.push('/login')
    localStorage.removeItem('token')
    console.log(userStore.userId);
    userStore.userId = ''
    userStore.islogined=false
}
// 如果手动清除localstorage中的数据，刷新页面登录页的状态无法正确显示，所以此处对是否登录进行设置
if(!localStorage.getItem('token')){
    userStore.islogined=false
    router.push('/login')
}
</script>
<style lang="scss" scoped>
.van-nav-bar {
    margin-bottom: 40px;
}
</style>
